package com.xinya.wanandroidclient.base;

import android.os.Bundle;
import android.util.Log;

/**
 * @ClassName: LazyBaseFragment$
 * @Description: 懒加载,避免多个fragment 一次加载过多，只有执行 onResume 的时候再去加载
 * @Author: xinya
 * @CreateDate: 2021/2/23$ 17:02$
 * @UpdateRemark: 更新内容
 * @Version: 1.0
 */
public abstract class LazyBaseFragment extends BaseFragment {
    private boolean isLoaded = false;

    @Override
    public void onResume() {
        super.onResume();

        if (!isLoaded && !isHidden()) {
            lazyInitView();
            isLoaded = true;
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        isLoaded = false;
    }

    @Override
    protected void init(Bundle savedInstanceState) {

    }

    protected abstract void lazyInitView();
}
